#!/usr/bin/env/python

# @author("Raymond Blum" <raymond@insanegiantrobots.com>)
# Copyright (c) 2013 by Raymond Blum
# This software is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# Use at your own risk
#

import time
from RPIO import PWM

PAN_PIN = 23
TILT_PIN = 24

servo = PWM.Servo()

def Tilt(tilt):
  servo.set_servo(TILT_PIN, tilt)

def Pan(pan):
  servo.set_servo(PAN_PIN, pan)

def Run():
  Tilt(1600)
  time.sleep(0.5)
  servo.stop_servo(TILT_PIN)

  for pan in range(150,220):
  	pan_back = 220-pan + 150
  	Pan(pan_back*10)
  	time.sleep(0.1)
  servo.stop_servo(PAN_PIN)

  Tilt(1300)
  time.sleep(0.5)
  servo.stop_servo(TILT_PIN)
  for pan in range(150,220):
  	Pan(pan*10)
  	time.sleep(0.1)
  servo.stop_servo(PAN_PIN)

  Tilt(1650)
  time.sleep(0.5)
  servo.stop_servo(TILT_PIN)
  time.sleep(1)

Run()
